<template>
  <div class="loading-box" v-show="show">
    <div class="loading-mask"></div>
    <div class="loading-content">
      <div class="animate">
      </div>
      <div class="text">{{text}}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    show: Boolean,
    text: {
      type: String,
      default: '正在加载中...'
    }
  }
}
</script>

<style lang="scss" scoped>
.loading-box {
  position: relative;
  text-align: center;
}

.loading-mask {
  position: fixed;
  background: #000;
  opacity: 0.2;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.loading-content {
  position: fixed;
  left: 50%;
  top: 250px;
  width: 180px;
  min-height: 120px;
  margin-left: -90px;
  padding: 10px;
  background: hsla(0, 0%, 7%, 0.7);
  text-align: center;
  border-radius: 5px;
  color: #fff;
  z-index: 5001;
}

.loading-content .animate {
  width: 40px;
  height: 40px;
  vertical-align: baseline;
  display: inline-block;
  margin: 25px 0 10px;
  vertical-align: middle;
  animation: superLoading 1s steps(12, end) infinite;
  background: transparent
    url("")
    no-repeat;
  background-size: 100%;
}

.loading-content .text {
  margin: 0 0 15px;
  font-size: 16px;
}

@-webkit-keyframes superLoading {
  0% {
    transform: rotate3d(0, 0, 1, 0deg);
  }
  100% {
    transform: rotate3d(0, 0, 1, 360deg);
  }
}

@keyframes superLoading {
  0% {
    transform: rotate3d(0, 0, 1, 0deg);
  }
  100% {
    transform: rotate3d(0, 0, 1, 360deg);
  }
}
</style>